package b2.widget.friend
{
	import b2.config.*;
	import b2.net.*;
	import b2.player.*;
	import b2.scene.*;
	import b2.util.*;
	import b2.widget.*;
	import b2.widget.tab.*;
	
	import flash.display.Sprite;
	import flash.events.*;
	import flash.filters.*;
	import flash.text.*;

	public class FriendTankItem extends Sprite
	{
		public function FriendTankItem(tankId:int)
		{
			super();
			//背景框
			var RoomPlayerItemBgr:Class = ResourceHelper.getInstance().getClassByName("RoomPlayerItemBgr");
			var roomPlayerItemBgr:Sprite = new RoomPlayerItemBgr();
			addChild(roomPlayerItemBgr);
			var tankInfo:TankInfo = PlayerInfoManager.getInstance().tanks[tankId];
			if (tankInfo == null)
			{
				//禁用标志
				var UnavailableBgr:Class = ResourceHelper.getInstance().getClassByName("EquipSlotBgr2");
				var unavailableBgr:Sprite = new UnavailableBgr();
				unavailableBgr.width = 40;
				unavailableBgr.height = 40;
				unavailableBgr.x = 12;
				unavailableBgr.y = 10;
				unavailableBgr.alpha = 0.2;
				addChild(unavailableBgr);
			}
			else
			{
				var tankConfig:TankConfig = Config.objectConfigs[tankInfo.index];
				//坦克图片
				var TankIcon:Class = ResourceHelper.getInstance().getClassByName(tankConfig.iconImage);
				var tankIcon:Sprite = new TankIcon();
				tankIcon.x = 10;
				tankIcon.y = 10;
				//齐天大圣
				if (tankInfo.index == 10015)
				{
					tankIcon.width = 74.25;
					tankIcon.height = 83.25;
				}
				//死亡骑士
				else if (tankInfo.index == 10020)
				{
					tankIcon.width = 65;
					tankIcon.height = 65;
				}
				else
				{
					tankIcon.width = 54;
					tankIcon.height = 54;
				}
				addChild(tankIcon);
				//名字
				var titleText:TextField = new TextField();
				titleText.selectable = false;
	        	titleText.autoSize = TextFieldAutoSize.CENTER;
				titleText.defaultTextFormat = new TextFormat("微软雅黑", 12, 0x000000);
				titleText.filters = [new GlowFilter(0xFFFFFF, 1, 1.3, 1.3, 100, BitmapFilterQuality.HIGH)];
				titleText.x = 38;
				titleText.y = 66;
				titleText.text = tankConfig.name;
				addChild(titleText);
				//战力图标
				var CampIcon:Class = ResourceHelper.getInstance().getClassByName("CampIcon");
				var fpIcon:Sprite = new CampIcon();
				fpIcon.width = 15;
				fpIcon.height = 15;
				fpIcon.x = 24;
				fpIcon.y = 8;
				addChild(fpIcon);
				//战力
				var fightPointText:TextField = new TextField();
				fightPointText.selectable = false;
	        	fightPointText.autoSize = TextFieldAutoSize.LEFT;
				fightPointText.defaultTextFormat = new TextFormat("微软雅黑", 12, 0xFFFFFF);
				fightPointText.filters = [new GlowFilter(0x000000, 1, 1.3, 1.3, 100, BitmapFilterQuality.HIGH)];
				fightPointText.x = 40;
				fightPointText.y = 4;
				fightPointText.text = tankInfo.fightPoint.toString();
				addChild(fightPointText);
			}
		}
		
	}
}